package com.dst.smart.dao.impl;

import java.util.List;
import com.dst.smart.dao.Database;
import com.dst.smart.model.ActionParam;
import com.dst.smart.model.Arce;
import com.dst.smart.model.CusDevice;
import com.dst.smart.model.Device;
import com.dst.smart.model.DeviceAction;
import com.dst.smart.model.DeviceFunction;
import com.dst.smart.model.DeviceType;
import com.dst.smart.model.FunctionParam;
import com.dst.smart.model.GateWay;
import com.dst.smart.model.GatewayType;
import com.dst.smart.model.Mode;
import com.dst.smart.model.ModeList;
import com.dst.smart.model.Products;
import com.dst.smart.model.RedInfra;
import com.dst.smart.model.Room;
import com.dst.smart.model.SubscribeInfo;
import com.dst.smart.model.VoiceInfo;

public class WidgetDAOProxy implements IWidgetDAO {
	private static Database dba = null;
	private static IWidgetDAO dao = null;
	public static WidgetDAOProxy instance;

	static {
		instance = new WidgetDAOProxy();
		dba = new Database();
		dao = new WidgetDAOImpl(dba.getSQLiteDatabase());

	}

	public static WidgetDAOProxy getInstance() {
		if (instance == null) {
			instance = new WidgetDAOProxy();
			dba = new Database();
			dao = new WidgetDAOImpl(dba.getSQLiteDatabase());
		}
		return instance;
	}

	public List<GateWay> getGateWay() {
		return dao.getGateWay();
	}

	public int updateVoice(VoiceInfo voiceInfo) {
		return dao.updateVoice(voiceInfo);
	}

	public List<GatewayType> getGateWayType() {
		return dao.getGateWayType();
	}

	public List<Mode> getMode() {
		return dao.getMode();
	}

	public List<DeviceFunction> getDeviceFunction() {
		return dao.getDeviceFunction();
	}

	public List<DeviceAction> getDeviceAction() {
		return dao.getDeviceAction();
	}

	public List<FunctionParam> getFunctionParam() {
		return dao.getFunctionParam();
	}

	public List<VoiceInfo> getVoice() {
		return dao.getVoice();
	}

	public List<ActionParam> getActionParam() {
		return dao.getActionParam();
	}

	public List<ModeList> getModeList() {
		return dao.getModeList();
	}

	public List<Products> getProducts() {
		return dao.getProducts();
	}

	public void updateCusDevice(List<CusDevice> list) {
		dao.updateCusDevice(list);
	}

	public int insertMode(Mode mode) {
		try {
			return dao.insertMode(mode);
		} catch (Exception e) {
			// TODO: handle exception
		}
		return 0;
	}

	public int updateMode(Mode mode, String modeName) {
		try {
			return dao.updateMode(mode, modeName);
		} catch (Exception e) {
			// TODO: handle exception
		}
		return 0;
	}

	public int updateDevice(Device device, String oldName) {
		try {
			return dao.updateDevice(device, oldName);
		} catch (Exception e) {
			// TODO: handle exception
		}
		return 0;
	}
	public int deleteDevice(int Id) {
		try {
			return dao.deleteDevice(Id);
		} catch (Exception e) {
			// TODO: handle exception
		}
		return 0;
	}
	public int insertDevice(Device device) {
		return dao.insertDevice(device);
	}

	public List<RedInfra> getInfrareds() {
		return dao.getInfrareds();
	}

	public int insertGateWay(GateWay gateWay) {
		try {
			return dao.insertGateWay(gateWay);
		} catch (Exception e) {
			// TODO: handle exception
		}
		return 0;
	}

	public int insertAction(DeviceAction deviceAction) {
		try {
			return dao.insertAction(deviceAction);
		} catch (Exception e) {
			// TODO: handle exception
		}
		return 0;
	}

	public int insertVoice(VoiceInfo voiceInfo) {
		try {
			return dao.insertVoice(voiceInfo);
		} catch (Exception e) {
			// TODO: handle exception
		}
		return 0;
	}

	public int insetFunction(DeviceFunction deviceFunction) {
		try {
			return dao.insetFunction(deviceFunction);
		} catch (Exception e) {
			// TODO: handle exception
		}
		return 0;
	}

	public int updateGateWay(GateWay gateWay, String gateWayName) {
		try {
			return dao.updateGateWay(gateWay, gateWayName);
		} catch (Exception e) {
			// TODO: handle exception
		}
		return 0;
	}

	public int updateIsCurrent(int id, int current) {
		return dao.updateIsCurrent(id, current);
	}

	public int deleteGateWay(int Id) {
		return dao.deleteGateWay(Id);
	}

	public int deleteVoice(int Id) {
		return dao.deleteVoice(Id);
	}
	public int deleteSubscribe(int Id) {
		return dao.deleteSubscribe(Id);
	}
	

	public List<Room> getRoom() {
		return dao.getRoom();
	}

	public List<CusDevice> getCusDevices() {
		return dao.getCusDevices();
	}

	public int insertRoom(Room room) {
		return dao.insertRoom(room);
	}

	public int updateRoom(Room room, String roomName) {
		return dao.updateRoom(room, roomName);
	}

	public int insertModeList(ModeList modeList) {
		return dao.insertModeList(modeList);
	}

	public int updateModeList(ModeList modeList) {
		return dao.updateModeList(modeList);
	}

	@Override
	public List<Device> getDevices() {
		// TODO Auto-generated method stub
		return dao.getDevices();
	}

	@Override
	public List<Device> getModeDevice(int modeById) {
		return dao.getModeDevice(modeById);
	}

	@Override
	public void updateModeSort(List<Mode> list) {
		dao.updateModeSort(list);
	}

	@Override
	public void updateRoomSort(List<Room> list) {
		dao.updateRoomSort(list);
	}

	@Override
	public void updateRoomHide(int homePageDisplays, int id) {
		dao.updateRoomHide(homePageDisplays, id);
	}

	@Override
	public List<DeviceType> getDeviceType() {
		return dao.getDeviceType();
	}

	@Override
	public void updateDeviceTypeSort(List<DeviceType> list) {
		dao.updateDeviceTypeSort(list);
	}

	public int deleteRoom(int id) {
		return dao.deleteRoom(id);
	}

	public int deleteRedFra(int id) {
		return dao.deleteRedFra(id);
	}

	public int deleteDevice(String deviceName) {
		return dao.deleteDevice(deviceName);
	}

	@Override
	public int deleteMode(int id) {
		// TODO Auto-generated method stub
		return dao.deleteMode(id);
	}

	@Override
	public int deleteMode(String modeName) {
		// TODO Auto-generated method stub
		return dao.deleteMode(modeName);
	}

	public int deleteModelist(int id) {
		return dao.deleteModelist(id);
	}

	public int deleteSyncData(String table) {
		return dao.deleteSyncData(table);
	}

	public int insertInfrad(RedInfra infrared) {
		return dao.insertInfrad(infrared);
	}

	public void insertProduct(Products products) {
		dao.insertProduct(products);
	}

	public int updateSubscribe(SubscribeInfo subscribeInfo) {
		return dao.updateSubscribe(subscribeInfo);
	}

	public int insertSubscribe(SubscribeInfo subscribeInfo) {
		return dao.insertSubscribe(subscribeInfo);
	}
	public List<SubscribeInfo> getSubScribe(){
		return dao.getSubScribe();
	}
}
